local H = require "packages/new_heg_my/util"
local U = require "packages/utility/utility"
local extension = Package:new("stable")
extension.extensionName = "new_heg_diy_my"
extension.game_modes_whitelist = { 'mul_heg_mode', 'ex_heg_mode', "zhonger_heg_mode" }

Fk:loadTranslationTable{
  ["stable"] = "日月交辉·固",
  ["wk_heg"] = "日月",
}

local sunru = General(extension, "wk_heg__sunru", "wu", 3, 3, General.Female)
local chishi = fk.CreateTriggerSkill{
  name = "wk_heg__chishi",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove, fk.EventPhaseChanging},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.AfterCardsMove then
      local cardTo = -99
      local cardInfo = {}
      for _, move in ipairs(data) do
        if move.from and move.from == player.id and move.to and move.to ~= player.id and move.toArea == Card.PlayerHand then
          for _, info in ipairs(move.moveInfo) do
            table.insert(cardInfo, info.cardId)
          end
          cardTo = move.to
        end
      end
      if #cardInfo > 0 and cardTo ~= -99 then
        self.cost_data = {cardInfo, cardTo}
        return true
      end
    else
      return player:hasSkill(self) and H.compareKingdomWith(target, player) and data.to == Player.Discard
       and (target:getMark("@!!yinyangfish") > 0 or target:getMark("@!!companion") > 0 or target:getMark("@!!vanguard") > 0 or target:getMark("@!!wild") > 0)
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
      if #self.cost_data > 0 then
        local to = room:getPlayerById(self.cost_data[2])
        room:throwCard(self.cost_data[1], self.name, to, to)
      end
    else
      data.to = Player.Play
    end
  end,
}

local xiecui = fk.CreateTriggerSkill{
  name = "wk_heg__xiecui",
  anim_type = "defensive",
  events = {fk.DamageInflicted, fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    if event == fk.Damaged then
      return player:hasSkill(self) and data.damageType ~= fk.NormalDamage and target:getMark("@!!yinyangfish") == 0
    else
      return player:hasSkill(self) and player == target
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.Damaged then
      return room:askForSkillInvoke(player, self.name, nil, "wk_heg__xiecui_getfish")
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.Damaged then
      H.addHegMark(room, target, "yinyangfish")
    else
      data.damageType = fk.FireDamage
    end
  end,
}
sunru.hidden = true
sunru:addSkill(chishi)
sunru:addSkill(xiecui)
sunru:addCompanions("zhonger_st_heg__luxun")
Fk:loadTranslationTable{
  ["wk_heg__sunru"] = "孙茹", --吴国
  ["designer:wk_heg__sunru"] = "老猫&教父",
  ["#wk_heg__sunru"] = "淑慎温良",

  ["wk_heg__xiecui"] = "撷翠",
  [":wk_heg__xiecui"] = "一名角色受到属性伤害后，若其没有“阴阳鱼”标记，你可令其获得一个“阴阳鱼”标记；你造成的伤害均为火焰伤害。",
  ["wk_heg__chishi"] = "持室",
  [":wk_heg__chishi"] = "与你势力相同的角色可以移去一个国战标记，将弃牌阶段改为出牌阶段；当你的牌被其他角色获得后，其弃置之。",

  -- ["wk_heg__xiecui_defense"] = "撷翠：你可以令其移去一个“阴阳鱼”标记，此伤害-1",
  -- ["wk_heg__xiecui_getfish"] = "撷翠：你可以令其获得一个“阴阳鱼”标记",
  -- ["#wk_heg__chishi_discard"] = "持室：你可以弃置至多体力上限数张牌，令当前回合角色本回合手牌上限增加等量值",

  ["$wk_heg__xiecui1"] = "东隅既得，亦收桑榆。",
  ["$wk_heg__xiecui2"] = "江东多娇，锦花相簇。",
  ["$wk_heg__chishi1"] = "柴米油盐之细，不逊兵家之谋。",
  ["$wk_heg__chishi2"] = "治大家如烹小鲜，须面面俱到。",
  ["~wk_heg__sunru"] = "从来无情者，皆出帝王家……",
}


return extension
